package csci4448.android.workouttracker;

import java.util.Locale;
public class ImperialSession extends Session
{
	public static final double SECONDS_PER_HOUR = 3600.0d;
	public static final double METERS_PER_MILE = 1609.344d;
	public ImperialSession(int SessionID, long DurationSeconds, double DistanceMeters, String StartTime, String EndTime, String SessionName)
	{
		super(SessionID, DurationSeconds, DistanceMeters, StartTime, EndTime, SessionName);
	}

	@Override
	public double getDistance(){
		return _distanceTravelledMeters / METERS_PER_MILE;
	}

	@Override
	public double getAverageSpeed() {
		return getDistance() / (getDurationSeconds() / SECONDS_PER_HOUR);
	}
	
	@Override
	public String getDurationString()
	{
		return String.format(Locale.getDefault(), "%02d:%02d:%02d", getDurationSeconds() / 3600, (getDurationSeconds() % 3600) / 60, (getDurationSeconds() % 60));
	}
	
	@Override
	public String getSpeedString()
	{
		return getSpeedString(getAverageSpeed());
	}
	
	@Override
	public String getSpeedString(double Speed) {
		if(Double.isNaN(Speed)){
			return String.format(Locale.getDefault(), "%.2f Mph", 0.0);
		} else {
			return String.format(Locale.getDefault(), "%.2f Mph", Speed);
		}
	}
	
	@Override
	public String getDistanceString()
	{
		return String.format(Locale.getDefault(), "%.2f Miles", getDistance());
	}

}
